Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial implementation of weapons predicting #217

Draft
wants to merge 21 commits into
base: master
Choose a base branch
from

Conversation

SNMetamorph
Copy link
Owner

ключевая идея такова, и состоит из нескольких шагов:
1) отделить весь код оружия от класса энтити оружия, вынести всю оружейную логику в серверсайдный CBaseWeaponLogic. класс энтити оружия должен иметь в себе только базовую инициализацию по типу задания модели и класснейма, ну и поинтер на CBaseWeaponLogic, через который будут прокидываться вызовы методов внутрь логики
2) далее, сделать код CBaseWeaponLogic компилируемым и на клиенте, и на сервере, отвязать его от серверсайдных классов/типов/функций
3) имплементировать на стороне клиента код предиктинга оружия. тут работа предстоит немаленькая.
4) как-то пофиксить save-restore у энтить оружия. как вариант, продублировать данные, которые требуется сохранить, в классе энтити оружия, а потом при загрузке/сохранении их записывать/читать из weapon logic объекта. в теории ничего в этом методе нерабочего нет, просто придётся на каждый класс писать кучку бойлерплейта.

@SNMetamorph SNMetamorph force-pushed the weapon-predicting branch 4 times, most recently from 87399b0 to 65cc5fb Compare September 7, 2024 17:52
@SNMetamorph SNMetamorph force-pushed the weapon-predicting branch 3 times, most recently from b2a79bd to f995120 Compare November 22, 2024 21:03
@SNMetamorph SNMetamorph force-pushed the weapon-predicting branch 2 times, most recently from 46752d2 to 8f987c2 Compare November 25, 2024 16:32
@SNMetamorph SNMetamorph force-pushed the weapon-predicting branch 3 times, most recently from 077a372 to 0437a27 Compare December 8, 2024 22:22
@SNMetamorph SNMetamorph force-pushed the weapon-predicting branch 5 times, most recently from be753c1 to b444f82 Compare December 22, 2024 13:35
@SNMetamorph SNMetamorph changed the title Initial implementation of weapon prediction Initial implementation of weapons predicting Dec 24, 2024
@SNMetamorph SNMetamorph force-pushed the weapon-predicting branch 3 times, most recently from c7c87b7 to ef36c10 Compare January 7, 2025 19:55
{
// Don't clear global fields
if (!m_global || !(pFields[i].flags & FTYPEDESC_GLOBAL))
memset(((char *)pBaseData + pFields[i].fieldOffset), 0, pFields[i].fieldSize * GetFieldSize(&pFields[i]));

Check failure

Code scanning / CodeQL

Multiplication result converted to larger type High

Multiplication result may overflow 'int' before it is converted to 'size_t'.

Copilot Autofix AI about 9 hours ago

To fix the problem, we need to ensure that the multiplication is performed using a larger integer type before the result is converted to size_t. This can be achieved by casting one of the operands to size_t before performing the multiplication. This way, the multiplication will be done in the size_t type, which is large enough to hold the result without overflow.

Specifically, we will modify the line pFields[i].fieldSize * GetFieldSize(&pFields[i]) to cast one of the operands to size_t before the multiplication. This change will be made in the file server/saverestore.cpp on line 1085.

Suggested changeset 1
server/saverestore.cpp

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/server/saverestore.cpp b/server/saverestore.cpp
--- a/server/saverestore.cpp
+++ b/server/saverestore.cpp
@@ -1084,3 +1084,3 @@
 			if (!m_global || !(pFields[i].flags & FTYPEDESC_GLOBAL))
-				memset(((char *)pBaseData + pFields[i].fieldOffset), 0, pFields[i].fieldSize * GetFieldSize(&pFields[i]));
+				memset(((char *)pBaseData + pFields[i].fieldOffset), 0, static_cast<size_t>(pFields[i].fieldSize) * GetFieldSize(&pFields[i]));
 		}
EOF
@@ -1084,3 +1084,3 @@
if (!m_global || !(pFields[i].flags & FTYPEDESC_GLOBAL))
memset(((char *)pBaseData + pFields[i].fieldOffset), 0, pFields[i].fieldSize * GetFieldSize(&pFields[i]));
memset(((char *)pBaseData + pFields[i].fieldOffset), 0, static_cast<size_t>(pFields[i].fieldSize) * GetFieldSize(&pFields[i]));
}
Copilot is powered by AI and may make mistakes. Always verify output.
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In progress
Development

Successfully merging this pull request may close these issues.

1 participant